package com.imcoke.abchat.web.controller;

import com.imcoke.abchat.common.annotation.FormValidation;
import com.imcoke.abchat.domain.json.JsonBasicUser;
import com.imcoke.abchat.domain.json.JsonEmail;
import com.imcoke.abchat.domain.json.JsonPassword;
import com.imcoke.abchat.domain.ResultBody;
import com.imcoke.abchat.web.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Author ccoke
 * @Description
 * @Date: 22:51 2017-11-29
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService mUserService;

    @FormValidation
    @PutMapping("/email")
    @ResponseBody
    public ResponseEntity<ResultBody> putEmail(@RequestBody JsonEmail jsonEmail) throws Exception {
        return ResponseEntity.ok(mUserService.firstEmail(jsonEmail));
    }

    @FormValidation
    @PutMapping("/password")
    @ResponseBody
    public ResponseEntity<ResultBody> putPassword(@RequestBody JsonPassword jsonPassword) {
        return ResponseEntity.ok(mUserService.modifyPassword(jsonPassword));
    }

    @PutMapping("/basic")
    @ResponseBody
    public ResponseEntity<ResultBody> putBasic(@RequestBody JsonBasicUser jsonBasicUser) {
        return ResponseEntity.ok(mUserService.modifyBasic(jsonBasicUser));
    }

}
